/**
 * Created by IntelliJ IDEA.
 * User: akolonitsky
 * Date: 12/16/11
 * Time: 11:07 AM
 * To change this template use File | Settings | File Templates.
 */
package model.vo
{
    import org.kolonitsky.alexey.utils.DateUtil;

    import view.screens.AnalyticScreen;

    public class ReportVO
    {
        public var title:String = "";

        /**
         *  The minimal date on timeline
         */
        public var beginDate:Date = null;

        /**
         * Maximal date on timeline
         */
        public var endDate:Date = null;

        /**
         *  List of log record for each
         */
        public var outgoingStatistic:Array /* of LogRecord */ = [];

        /**
         *
         */
        public var incomingStatistic:Array /* of LogRecord */ = [];

        /**
         * Full incoming balance for initial log
         */
        public var incomingBalance:LogRecord = new LogRecord("incoming balance");

        /**
         * Full outgoing balance for initial log
         */
        public var outgoingBalance:LogRecord = new LogRecord("outgoing balance");

        /**
         * Outgoing untagged balance for initial balance
         */
        public var outgoingUntaggedBalance:LogRecord = new LogRecord("untagged outgoing balance");

        /**
         * Outgoing untagged balance for initial balance
         */
        public var incomingUntaggedBalance:LogRecord = new LogRecord("untagged incoming balance");

        /**
         *
         */
        public var log:Array /* LogRecord */ = [];

        /**
         *
         */
        public function get daysCount():int
        {
            var delta:Number = endDate.time - beginDate.time;
            return (delta - (delta % DateUtil.MILISECONDS_PER_DAY)) / DateUtil.MILISECONDS_PER_DAY
        }

        /**
         *
         * @param title
         */
        public function getDateByIndex(index:int):Date
        {
            return (log[index] as LogRecord).date;
        }

        /**
         *
         * @param date
         * @return
         */
        public function getIndexByDate(date:Date):int
        {
            DateUtil.round(beginDate, DateUtil.MILISECONDS_PER_DAY);
            DateUtil.round(date, DateUtil.MILISECONDS_PER_DAY)
            var result:int = (date.time - beginDate.time) / DateUtil.MILISECONDS_PER_DAY;
            return result;
        }

        /**
         *
         * @param date
         * @return
         */
        public function getRecordByDate(date:Date):LogRecord
        {
            var index:int = getIndexByDate(date);
            return log[index];
        }

        public function ReportVO(title:String)
        {
            this.title = title;
        }
    }
}
